package com.wnxy.admin.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wnxy.admin.dto.ReservationDto;
import com.wnxy.admin.entity.Reservation;
import com.wnxy.admin.mapper.ReservationMapper;
import com.wnxy.admin.service.IReservationService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 预约表 服务实现类
 * </p>
 *
 * @author All
 * @since 2023-11-29
 */
@Service
public class ReservationServiceImpl extends ServiceImpl<ReservationMapper, Reservation> implements IReservationService {

    private final ReservationMapper reservationMapper;

    public ReservationServiceImpl(ReservationMapper reservationMapper) {
        this.reservationMapper = reservationMapper;
    }


    @Override
    public PageInfo<ReservationDto> getAll(Integer pageNum, Integer pageSize, String keyword) {
        PageHelper.startPage(pageNum, pageSize);
        if (keyword == null) {
            keyword = "";
        }
        List<ReservationDto> reservationDtos = reservationMapper.selectAll(keyword);
        return new PageInfo<>(reservationDtos);
    }

    @Override
    public PageInfo<ReservationDto> getByCustomerId(Integer pageNum, Integer pageSize, String keyword, Integer id) {
        PageHelper.startPage(pageNum, pageSize);
        if (keyword == null) {
            keyword = "";
        }
        List<ReservationDto> reservationDtos = reservationMapper.selectByCustomerId(keyword,id);
        return new PageInfo<>(reservationDtos);
    }
}
